package cfca.paperless.client.servlet._4_manager._4_03_AutoUpdateSealApplyInfo;

import cfca.paperless.client.servlet.PaperlessConfig;
import cfca.paperless.client.servlet.PaperlessManagerClient;
import cfca.paperless.client.util.StringUtil;

/**
 * @Description 自动化更新用户信息接口，使用示例。 
 * 1，更新印章申请用户的电话号码。
 * 
 * @Author dell
 * @Date 2016-5-13
 * @CodeReviewer TODO
 */
public class AutoUpdateSealApplyInfoTest01 {

    public static void main(String[] args) throws Exception {
        try {
            PaperlessManagerClient clientBean = new PaperlessManagerClient(PaperlessConfig.managerUrl, 10000, 60000);// 无纸化管理接口的访问URL

            StringBuilder sb = new StringBuilder();
            sb.append("<SealApplyInfo>");
            sb.append("<SealCode>").append("6816566660").append("</SealCode>");// 已经在服务端生成的、需要做更新用户信息所关联的印章编码
            sb.append("<UserName>").append("").append("</UserName>");// 印章编码为空时，用如下三要素定位
            sb.append("<IdentificationType>").append("").append("</IdentificationType>");
            sb.append("<IdentificationNo>").append("").append("</IdentificationNo>");
            sb.append("<SealFlag>").append("0").append("</SealFlag>");// 印章标识，默认0代表普通印章
            sb.append("</SealApplyInfo>");
            String oldSealApplyInfoXml = sb.toString();
            System.out.println(oldSealApplyInfoXml);

            StringBuilder sbb = new StringBuilder();
            sbb.append("<SealApplyInfo>");
            sbb.append("<PhoneNo>").append("15811274851").append("</PhoneNo>");// 电话号码
            sbb.append("</SealApplyInfo>");
            String newSealApplyInfoXml = sbb.toString();
            System.out.println(newSealApplyInfoXml);

            // 操作员编码或者机构号
            String operatorCode = PaperlessConfig.operatorCode;

            String result = clientBean.autoUpdateSealApplyInfo(oldSealApplyInfoXml, newSealApplyInfoXml, operatorCode);

            String code = StringUtil.getNodeText(result, "Code");

            if ("200".equals(code)) {
                System.out.println("OK:autoUpdateUserInfo");
                System.out.println(result);
            } else {
                // Code不等于200时为异常,处理结果为异常，打印出错误码和错误信息
                System.out.println("NG:autoUpdateUserInfo");
                System.out.println(result);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
